package com.lk.springboot.dao;

import java.util.List;

import com.lk.springboot.bean.Category;
import com.lk.springboot.bean.Press;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface CategoryMapper {

    @Select("select * from  book ")
    List<Category> findAll();

    @Select("select * from  book where title like concat('%',#{title},'%')")
    List<Category> findByTitle(String title);

    @Select("select * from  book where author like concat('%',#{author},'%')")
    List<Category> findByAuthor(String author);

    @Insert(" insert into  book (p_id, title , author, price , sprice ,date ) values (#{p_id},#{title},#{author},#{price},#{sprice},#{date}) ")
    public int save(Category category);

    @Delete(" delete from  book where b_id= #{b_id} ")
    public void delete(int b_id);

    @Select("select * from  book where b_id= #{b_id} ")
    public Category get(int b_id);

    @Update("update  book set title=#{title},author=#{author},price=#{price},sprice=#{sprice},date=#{date} where b_id=#{b_id} ")
    public int update(Category category);

}